home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 015a / seemem.zip / SEEMEM.DOC next >
Text File  |  1991-10-18  |  13KB  |  230 lines

  1.  
  2.  
  3.  
  4.  
  5.                                 SEEMEM.EXE
  6.  
  7.  
  8.           Author:             Tedrick A. Housh, Jr.
  9.                               5811 West 85th Terrace
  10.                               Overland Park, KS 66207
  11.  
  12.  
  13.           Electronic Mail:    CompuServe 72466,212
  14.                               GEnie      RHOUSH
  15.  
  16.  
  17.      The objective of SEEMEM is to display information about the
  18.      current use of MS-DOS memory by the operating system, and
  19.      resident processes and data.
  20.  
  21.      It is designed to make full use of the new memory facilities
  22.      provided by DOS version 5.0, and to provide information similar
  23.      to the provided by the DOS utility MEM.  However, it provides
  24.      this information even when DOS does not control Upper or Extended
  25.      memory, and even when HIMEM.SYS and EMM386.EXE are not loaded,
  26.      and recognizes UMB's created by other programs, such as
  27.      Quarterdeck Software's QEMM386 (for 386 and higher) and QRAM (for
  28.      286 cpu's with EMS version 4.00 hardware or Chips and
  29.      Technologies Shadow Ram).  It works with these programs on all
  30.      versions of DOS greater than 1, and on all CPU chips, 8088 and
  31.      higher, although the memory detail displayed increases with
  32.      increase in CPU version.
  33.  
  34.      SEEMEM was written in Turbo Pascal 6.00, as an exercise in the
  35.      use of the Built-In Assembler (BASM).  In that connection, all
  36.      necessary DOS functions were specifically coded in BASM, as were
  37.      all functions which necessarily interface with the extended
  38.      memory (XMS) driver provided by HIMEM.SYS, or its counterparts
  39.      such as QEMM386.SYS, or QEXT.SYS, or EMM386.SYS or QEXT.SYS.
  40.      This completely eliminates the need for the Turbo Pascal DOS
  41.      unit, or a unit to interface with the XMS and UMB device drivers.
  42.      All the low level functions necessary for this purpose are
  43.      included directly in the SEEMEM.PAS file as BASM code, and the
  44.      .PAS file is independent and completely self-supporting.
  45.  
  46.      The display output for SEEMEM is in three parts.  The first part,
  47.      which may include several screen pages displays every memory
  48.      control block (MCB) between Segment 0 and the top of conventional
  49.      memory (Segment 9FFFh on a 640k machine), and also between the
  50.      top of conventional memory and the start of the High Memory Area
  51.      (HMA) if any, or the top of Upper Memory (Segment 0FFFFh).  For
  52.      each MCB SEEMEM displays its segment address (in hex), its size
  53.      (in both Kilobytes and bytes), the segment of its "owner," its
  54.      type (e.g. Process or Environment), and its name (if
  55.      determinable).
  56.  
  57.      The second part is a display of EMS (Expanded Memory) if
  58.      applicable.  This displays the version number of the EMS device
  59.      driver, the page frame segment, the total size of the installed
  60.      EMS memory, the number of mapping register sets available,
  61.      whether or not nonvolatile handles (will survive warm boot) are
  62.      available, the number of DMA channels , the maximum number of EMS
  63.      handles supported, the number of free handles, free pages, page
  64.      size, and free memory, and for each handle in use, the handle
  65.      number, the number of EMS pages, the page size, the memory used,
  66.      and if available, the handle name.  This second part may occupy
  67.      more than one screen page.
  68.  
  69.      The third part displays XMS information (if a driver is
  70.      installed), including XMS version number, revision number, the
  71.      XMM Control Vector in segment:offset form, total XMS free memory,
  72.      and largest free XMS block.  With respect to the High Memory Area
  73.      (HMA) SEEMEM shows whether the A20 line is currently enabled,
  74.      whether HMA is implemented, whether the HMA is available for use.
  75.      If the DOS version is 5.00 or greater SEEMEM also will say
  76.      whether DOS is resident in the HMA (DOS=HIGH in config.sys), and,
  77.      if so, how much of the HMA DOS has left available for additional
  78.      buffers, etc.  SEEMEM also displays the location of DOS when it
  79.      is located elsewhere (i.e. ROM or Conventional memory).
  80.  
  81.      The third part also displays information about Upper Memory
  82.      Blocks (UMB's) if available:  whether UMB's are implemented,
  83.      whether they are controlled by device driver or by DOS itself
  84.      (with DOS 5.00 and higher), whether UMB's are linked to
  85.      conventional memory (DOS 5.00) or are independent, and whether
  86.      UMB's are implemented by DOS=UMB in CONFIG.SYS (DOS 5.00).
  87.  
  88.      Seemem does NOT display device driver information loaded under
  89.      DOS version 4.xx or higher's "secondary" MCB's, although it will
  90.      display such primary MCB's other software may use to load such
  91.      device driver's "high" in UMB's if each is given its own MCB.
  92.      This was a design decision to avoid "clutter."  Plenty of
  93.      programs are available to "walk" the device chain and display
  94.      this information.
  95.  
  96.      A word about resident code names is in order. Under DOS 2.xx the
  97.      name of resident code is not determinable.  With DOS 3.xx the
  98.      name may be determined from the environment, unless that was
  99.      released back to DOS's pool on installation.  With DOS 4.xx and
  100.      higher an eight character name is inserted in the last eight
  101.      bytes of the 16 byte MCB, and therefore is always available.
  102.      Some other programs which control UMB's insert the eight
  103.      character name in the MCB under any DOS version, but this is not
  104.      used by SEEMEM.  SEEMEM uses the most detailed information
  105.      available.  Therefore, if the DOS version is 4 or higher, and the
  106.      environment pertaining to the process is still resident, the
  107.      program name and extension is taken from the environment
  108.      (although the drive and directory information is stripped from
  109.      the filename before display).
  110.  
  111.      A full explanation of the XMS and UMB, and HMA standards is not
  112.      within the scope of this documentation, however an understanding
  113.  
  114.      of a few of the more obscure facts will help understand SEEMEM's
  115.      operation.   The "XMS Specification" for extended memory is
  116.      similar to the EMS spec for expanded memory.  It provides
  117.      functions for implementing use of extended memory with handles in
  118.      a manner very much the same as EMS does for expanded memory.  The
  119.      High Memory Area (HMA) is the 64 kilobyte (less 16 bytes) just
  120.      above the 1 megabyte limit of the 8086 and 8088 chips.
  121.      Obviously, then XMS extended memory and the HMA require a '286
  122.      chip or higher.  However, through a clever addressing scheme, and
  123.      an additional hardware address line, an 80286 or higher can
  124.      address the HMA in "real" mode, i.e. as "non-extended" memory.
  125.      Although XMS drivers before DOS 5.00, and some alternative DOS-
  126.      like operating systems allowed the use of this space for some
  127.      things, DOS 5.00 now allows DOS itself to be loaded there,
  128.      substantially increasing the possible useable memory space in
  129.      lower memory previously used by DOS.
  130.  
  131.      Although the protocols and specifications for Upper Memory Blocks
  132.      (UMB's) are contained in the original XMS specifications, they
  133.      are NOT necessarily part of the XMS driver itself, and in fact
  134.      were not implemented by the first MicroSoft driver, HIMEM.SYS.
  135.      The XMS specification only provides one control vector however,
  136.      so if all UMB calls need be implemented through that vector, a
  137.      UMB driver must be integrated with the XMS driver, or must hook
  138.      that vector (necessarily implying that it must be loaded after
  139.      the XMS driver has installed the vector) unless it is completely
  140.      integrated.  However DOS 5.00 has supplied interrupt 21h function
  141.      calls to manipulate the use of existing UMB's for detecting the
  142.      existence, state and governing the rules of use of UMB's, and
  143.      these function calls are not dependent on the existence of any
  144.      device driver, nor for that matter, the existence of any extended
  145.      memory, or a chip higher than that 8088-8086.  The thought may
  146.      take some getting used to, but this means that UMB's can exist
  147.      without any driver or control vector at all.  In fact there is at
  148.      least one program available which acts as though it were a device
  149.      driver, creates UMB's from Chips and Technologies shadow ram,
  150.      hands it over to DOS, and then just aborts, itself disappearing
  151.      from memory.  DOS then owns, and makes available, some UMB's with
  152.      no device driver to control them.  SEEMEM can even detect this
  153.      type of UMB and display its state.
  154.  
  155.      DOS 5.00 provides greatly increased support for XMS, HMA, and
  156.      UMB's, and SEEMEM uses all of it, where it is possible to do so.
  157.  
  158.      In order that it may support full display redirection SEEMEM does
  159.      not do any direct video memory-mapped display.  All display is
  160.      through DOS or BIOS.  Each screen is paged with a "MORE" line at
  161.      the bottom UNLESS the /N ("NO PAUSE") switch is used.  The only
  162.      other switch available is the help /H or /? switch, which
  163.      displays a simple help message.  The output may be directed to a
  164.      file or a device such as a printer, in which case you will
  165.      probably wish to bypass paging also, with the /n switch.
  166.  
  167.      For example SEEMEM /N > PRN  would send the output of the program
  168.      to the printer for a permanent record.  In order to speed the
  169.      output slightly the DOS IOCTL function is used to switch to "raw"
  170.  
  171.      output mode, and is returned to its prior state, probably
  172.      "cooked" upon program termination.  This speeds up output by
  173.      eliminating checks for ^S, ^Q, ^C and expansion of tabs, etc., so
  174.      you cannot manually pause the program or "break" it.  No tabs or
  175.      other characters requiring interpretation are used however, so
  176.      you should see no difference due to disallowance of "cooked"
  177.      mode.
  178.  
  179.      If you insist on a "scrollable" output I have successfully used
  180.      the J.P. Software's 4DOS command shell internal LIST command with
  181.      SEEMEM to provide this with the following command line:
  182.  
  183.        SEEMEM /N | LIST
  184.  
  185.      This provides an output which uses LIST to scroll from top to
  186.      bottom.
  187.  
  188.      This version (1.00B) of SEEMEM must be considered a beta version.
  189.      Although it is believed to operate as described, I simply do not
  190.      have a sufficiently diverse group of computers to test it on to
  191.      determine that such a hardware specific program will work
  192.      properly with all hardware configurations.  Thus no warranties or
  193.      guarantees of any kind are made.
  194.  
  195.      I have made the source code available in Turbo Pascal 6.0 on the
  196.      Borland Support area on GEnie and in the Borland Programming A
  197.      area in CompuServe as SEEMTP.ZIP.  The program is copyright but
  198.      donated to the public domain without any restriction, except
  199.      that it be distributed in its original form with appropriate
  200.      authorship credit, with no charge other than reasonable fees for
  201.      duplication and distribution, including by electronic means.  It
  202.      is specifically intended and permission is granted for
  203.      distribution by commercial electronic sources for their regular
  204.      and customary access and membership fees even though they may be
  205.      operated for profit.
  206.  
  207.      The basic idea for SEEMEM is not new, of course and all
  208.      parts of it borrow heavily upon prior, similar programs.  Perhaps
  209.      it should be named YAMEM (Yet Another MEMory display program).
  210.      Nevertheless it does do some things no other does (that I know
  211.      of) and it is a demonstration of Turbo Pascal 6's BASM facility
  212.      which clearly shows the practicality of the TP environment for
  213.      low level system programming.  In fact, I don't think the same
  214.      thing could be done in C with faster or smaller code resulting.
  215.      Yeah, I know, TP is primarily a shell for the assembly stuff, but
  216.      at least it can do that now, and very adroitly, too.
  217.  
  218.      I am considering writing a comprehensive XMS, UMB, and HMA Turbo
  219.      Pascal Unit to implement the services supplied by device drivers
  220.      under the XMS-UMB specification, which would also implement the
  221.      new DOS 5.00 services connected to these facilities.  I would be
  222.      interested in hearing from those who might want or need such a
  223.      unit.  Of course, feedback on the use of SEEMEM would be
  224.      appreciated, and I will be glad to provide help through E-Mail at
  225.      the above addresses, or through the post, but I am not in a
  226.      position to provide any real-time telephone support.
  227.  
  228.                           Rick Housh
  229.  
  230.